package com.opo5.logisticsmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.opo5.logisticsmanagement.dao.CablePlanDao;
import com.opo5.logisticsmanagement.dao.LedgerDao;
import com.opo5.logisticsmanagement.domain.CablePlan;
import com.opo5.logisticsmanagement.domain.Ledger;
import com.opo5.logisticsmanagement.domain.New;
import com.opo5.logisticsmanagement.service.LedgerService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
@Service
public class LedgerServiceImpl extends ServiceImpl<LedgerDao,Ledger> implements LedgerService {
    @Autowired(required = false)
    private LedgerDao ledgerDao;
    @Override
    public IPage<Ledger> selectPage1(int currentPage, int pageSize,String startTime,String finishTiem,Ledger ledger) {
        LambdaQueryWrapper<Ledger>lqw=new LambdaQueryWrapper<>();
        lqw.eq(ledger.getPlantype()!=null,Ledger::getPlantype,ledger.getPlantype());
        lqw.eq(ledger.getOperatetype()!=null,Ledger::getOperatetype,ledger.getOperatetype());
        lqw.ge(startTime!=null,Ledger::getOperatetime,startTime);
        lqw.le(finishTiem!=null,Ledger::getOperatetime,finishTiem);
        IPage<Ledger>page=new Page<>(currentPage,pageSize);
        ledgerDao.selectPage(page,lqw);
        return page;
    }

    @Override
    public IPage<Ledger> selectBilling(int currentPage, int pageSize, Ledger ledger) {
        LambdaQueryWrapper<Ledger>lqw=new LambdaQueryWrapper<>();
        System.out.println(ledger);
        lqw.eq(Ledger::getFinishstate,1);
        lqw.eq(Strings.isNotEmpty(ledger.getPlantype()),Ledger::getPlantype,ledger.getPlantype());
        lqw.eq(Strings.isNotEmpty(ledger.getBillingstate()),Ledger::getBillingstate,ledger.getBillingstate());
        lqw.eq(Strings.isNotEmpty(ledger.getProjectnum()),Ledger::getProjectnum,ledger.getProjectnum());
        IPage<Ledger>page=new Page<>(currentPage,pageSize);
        ledgerDao.selectPage(page,lqw);
        return page;
    }
}
